/*
 * @Author: xujianxing
 * @Date: 2020-02-15 12:55:51
 * @LastEditors  : xujianxing
 * @LastEditTime : 2020-02-16 13:51:41
 * @Description: 连接MySql测试文件
 */
var mysql = require("mysql");
var pool = mysql.createPool({
  host: "localhost",
  port: 3306,
  user: "root",
  password: "jjxx8980",
  database: "zhipin",
  multipleStatements: true
});
function query(sql, params, cb) {
  pool.query(sql, params, (err, vals, fields) => {
    cb(err, vals, fields);
  });
}

const sql = "select * from test";
const insertSql =
  "insert into zhipin.user(zid,username,password) VALUES(REPLACE(uuid(),'-',''),?,?)";
const params = ["admin5", "new123", Date.now()];
query(insertSql, params, (err, vals, fields) => {
  console.log(err, vals, fields);
  pool.end();
});
